<html>
<head><meta charset="utf-8"><title>coercions considered harmful: async fn and Stacked Borrows · t-lang/wg-unsafe-code-guidelines · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/index.html">t-lang/wg-unsafe-code-guidelines</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/coercions.20considered.20harmful.3A.20async.20fn.20and.20Stacked.20Borrows.html">coercions considered harmful: async fn and Stacked Borrows</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="148731945"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/coercions%20considered%20harmful%3A%20async%20fn%20and%20Stacked%20Borrows/near/148731945" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/coercions.20considered.20harmful.3A.20async.20fn.20and.20Stacked.20Borrows.html#148731945">(Nov 28 2018 at 18:25)</a>:</h4>
<p>See <a href="https://github.com/solson/miri/issues/532#issuecomment-442552764" target="_blank" title="https://github.com/solson/miri/issues/532#issuecomment-442552764">https://github.com/solson/miri/issues/532#issuecomment-442552764</a>: If my analysis is correct, <code>async fn</code> violates Stacked Borrows, but that's just a silly mistake that went unnoticed only because mutable references implicitly coerce to shared references.</p>



<a name="148751125"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/coercions%20considered%20harmful%3A%20async%20fn%20and%20Stacked%20Borrows/near/148751125" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ariel Ben-Yehuda <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/coercions.20considered.20harmful.3A.20async.20fn.20and.20Stacked.20Borrows.html#148751125">(Nov 28 2018 at 23:07)</a>:</h4>
<p>a.k.a. why my ACA model did not treat mutable references as "asserting" (i.e. popping the stack) until they are used to some degree.</p>



<a name="148751246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/coercions%20considered%20harmful%3A%20async%20fn%20and%20Stacked%20Borrows/near/148751246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ariel Ben-Yehuda <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/coercions.20considered.20harmful.3A.20async.20fn.20and.20Stacked.20Borrows.html#148751246">(Nov 28 2018 at 23:09)</a>:</h4>
<p>of course, that approach has the disadvantage of forcing a tree instead of a stack.</p>



<a name="148751449"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/coercions%20considered%20harmful%3A%20async%20fn%20and%20Stacked%20Borrows/near/148751449" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ariel Ben-Yehuda <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/coercions.20considered.20harmful.3A.20async.20fn.20and.20Stacked.20Borrows.html#148751449">(Nov 28 2018 at 23:12)</a>:</h4>
<p>it's somewhat weird to see that the examples that violate this are clearly mistakes, rather than being just dubious unsafe code.</p>



<a name="148751458"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/coercions%20considered%20harmful%3A%20async%20fn%20and%20Stacked%20Borrows/near/148751458" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ariel Ben-Yehuda <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/coercions.20considered.20harmful.3A.20async.20fn.20and.20Stacked.20Borrows.html#148751458">(Nov 28 2018 at 23:12)</a>:</h4>
<p>(I expected it to be mainly dubious unsafe code that just uses &amp;mut as intermediates).</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>